Skip to content

add blank line before ATX-style headings to avoid ambiguity #178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

chrispy-snps
Copy link
Collaborator

@chrispy-snps chrispy-snps commented Jan 19, 2025

Fixes the headings part of #176.

A blank line is inserted before ATX-style headings (open and closed). Unit tests are updated.

For example,

import markdownify

md = markdownify.MarkdownConverter(heading_style="ATX").convert

print(md(html="<h1>Heading 1</h1>TEXT<h2>Subheading</h2>TEXT<h1>Heading 2</h1>TEXT"))

results in

# Heading 1

TEXT

## Subheading

TEXT

# Heading 2

TEXT

Signed-off-by: chrispy <chrispy@synopsys.com>
@chrispy-snps chrispy-snps force-pushed the chrispy/add-blank-line-before-atx-headings branch from 1a9f278 to 1ecdffa Compare January 19, 2025 02:57
@chrispy-snps chrispy-snps requested a review from AlexVonB January 19, 2025 02:58
Copy link
Collaborator

@AlexVonB AlexVonB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be an extension to 60d8666, which added the first newline. A second newline is sensible. Generally, we want to minimize unneeded whitespace (see #151), but this change looks good.

@chrispy-snps chrispy-snps merged commit f24ec9e into matthewwithanm:develop Jan 21, 2025
1 check passed
@chrispy-snps chrispy-snps deleted the chrispy/add-blank-line-before-atx-headings branch February 17, 2025 13:45
Wuhall pushed a commit to Wuhall/python-markdownify that referenced this pull request May 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants